/*
 *   SSCatalystDocument.h
 *  MESLib
 * 
 * Copyright 2003-2009 Starline Software Ltd
 * 
 * This file is part of MESLib.
 * 
 * MESLib is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MESLib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with MESLib. If not, see <http://www.gnu.org/licenses/>.
 */
//  Created by Tobias Haughton on Tue Jan 21 2003.
//

#import <AppKit/AppKit.h>
#import "SSXMLParser.h"
#import "SSEventObject.h"
#import "SSChartView.h"
#import "SSCatalystDocumentData.h"
#import "SSInspectorController.h"
#import "SSNeedsDiamond.h"
#import "SSJumpMapView.h"
#import "SSTablePrintView.h"
#import "SSObjectFilterController.h"
#import "SSObjectFilterPanelController.h"
#import "SSOverlapScaleAndRangePanelController.h"
#import "SSOverlapSwitchScaleAndRangeController.h"
#import "BigTableHeaderCell.h"
#import "SSPoisonWord.h"
#import "SSTextEntryValidationMK2.h"

@interface SSCatalystDocument : NSDocument {
   IBOutlet id legendView;
   IBOutlet SSChartView *chartView;
   IBOutlet id tableView;
   IBOutlet id splitView;
   IBOutlet id dateDisplayView;

   IBOutlet id printWindow;
   IBOutlet id printChartView;
   IBOutlet id printDateDisplayView;
   IBOutlet id printTableView;
   IBOutlet id printLegendView;
   IBOutlet id printPanelAccessoryView;
   IBOutlet id printPanelPagesWideField;
   IBOutlet id printPanelPagesHighField;

   SSCatalystDocumentData *documentData;
   NSMutableArray *missingFiles; //just used while loading
   NSMutableArray *actorOrder; //just used while loading
   NSArray *draggedRows; //used for dragging actor rows
   NSMutableArray *skippedImportedEvents; //array of skiped events that will be deleted after import
   SSJumpMapView *jumpMapView;
   int editingMode;
   BOOL catalystDocument;
   SSObjectFilterController *objectFilterController;
   int printPagesWide, printPagesHigh;
   NSString *outputString;
}

- (IBAction)scalePrintToNumPages:(id)sender;
- (IBAction)stepEBBack:(id)sender;
- (IBAction)stepEBForward:(id)sender;

//loadind/saving
- (NSFileWrapper *)catalystFileWrapperRepresentation:(NSMutableDictionary *)dict;
- (NSFileWrapper *)catalystCompressedFileWrapperRepresentation;
- (NSMutableArray *)eventArray;
- (BOOL)loadDocumentWithFileWrapper:(NSFileWrapper *)wrapper;
- (BOOL)loadCompressedDocumentWithFileWrapper:(NSFileWrapper *)wrapper;
- (void)importFiles;

- (void)addFilesFromDictionary:(NSDictionary *)fileDictionary structureDict:(NSMutableDictionary *)structureDict appendAddress:(NSString *)appendToFront;
- (void)addEventToDocument:(SSEventObject *)event;
- (void)addEventToAalosDictionary:(SSEventObject *)event;
- (NSString *)dataSourceDictionaryArrayWithKey:(NSString *)key objectAtIndex:(int)index;
- (NSString *)alphabeticDataSourceDictionaryArrayWithKey:(NSString *)key objectAtIndex:(int)index;
- (int)dataSourceDictionaryIndexOfObject:(NSString *)object inArray:(NSString *)arrayName;
- (NSMutableArray *)filteredActorArray;
- (int)numberOfUniqueLocations;
- (int)numberOfUniqueActions;
- (int)numberOfUniqueActors;
- (int)numberOfUniqueObjects;
- (int)numberOfUniqueSources;
- (int)numberOfUniqueRemarks;
- (int)numberOfActorsWithName:(NSString *)name;

- (NSString *)title;
- (void)setTitle:(NSString *)string;
- (NSString *)author;
- (void)setAuthor:(NSString *)string;
- (NSCalendarDate *)chartDate;
- (void)setChartDate:(NSCalendarDate *)date;
- (NSString *)whiteColorDesignation;
- (void)setWhiteColorDesignation:(NSString *)string;
- (NSString *)yellowColorDesignation;
- (void)setYellowColorDesignation:(NSString *)string;
- (NSString *)greenColorDesignation;
- (void)setGreenColorDesignation:(NSString *)string;
- (NSString *)lightBlueColorDesignation;
- (void)setLightBlueColorDesignation:(NSString *)string;
- (NSString *)blueColorDesignation;
- (void)setBlueColorDesignation:(NSString *)string;
- (NSString *)purpleColorDesignation;
- (void)setPurpleColorDesignation:(NSString *)string;
- (NSString *)orangeColorDesignation;
- (void)setOrangeColorDesignation:(NSString *)string;
- (NSString *)redColorDesignation;
- (void)setRedColorDesignation:(NSString *)string;

- (NSString *)diamondUDValue1;
- (void)setDiamondUDValue1:(NSString *)string;
- (NSString *)diamondUDValue2;
- (void)setDiamondUDValue2:(NSString *)string;
- (NSString *)diamondUDValue3;
- (void)setDiamondUDValue3:(NSString *)string;
- (NSString *)diamondUDValue4;
- (void)setDiamondUDValue4:(NSString *)string;
- (NSString *)diamondUDValue5;
- (void)setDiamondUDValue5:(NSString *)string;
- (NSString *)diamondUDValue6;
- (void)setDiamondUDValue6:(NSString *)string;
- (NSString *)diamondOptionUDValue1;
- (void)setDiamondOptionUDValue1:(NSString *)string;
- (NSString *)diamondOptionUDValue2;
- (void)setDiamondOptionUDValue2:(NSString *)string;
- (NSString *)diamondOptionUDValue3;
- (void)setDiamondOptionUDValue3:(NSString *)string;
- (NSString *)diamondOptionUDValue4;
- (void)setDiamondOptionUDValue4:(NSString *)string;
- (NSString *)diamondOptionUDValue5;
- (void)setDiamondOptionUDValue5:(NSString *)string;
- (NSString *)diamondTradeoffUDValue1;
- (void)setDiamondTradeoffUDValue1:(NSString *)string;
- (NSString *)diamondTradeoffUDValue2;
- (void)setDiamondTradeoffUDValue2:(NSString *)string;
- (NSString *)diamondTradeoffUDValue3;
- (void)setDiamondTradeoffUDValue3:(NSString *)string;

- (NSString *)projectFolder;
- (void)setProjectFolder:(NSString *)path;

- (void)setupToolbar;
- (void)showNewEBPanel;
- (BOOL)isValidMESFileName:(NSString *)string;

- (NSBitmapImageRep *)chartImage;
- (NSData *)glossaryDataForType:(NSString *)type;
- (NSData *)remarkListData;
- (NSData *)eventListData;
- (NSData *)commentListData;
- (NSData *)diamondListData;
- (NSData *)optionGlossaryData;
- (NSData *)proTradeoffGlossaryData;
- (NSData *)conTradeoffGlossaryData;

- (void)addEventToChartView:(SSEventObject *)event;
- (void)addCommentToChartView:(SSCatalystComment *)com;

- (NSMutableArray *)commentArray;

- (void)addNewEventBlock:(SSEventObject *)event;

- (void)addCommentOfType:(NSNumber *)type;
- (void)addCommentToDocument:(SSCatalystComment *)comment;
- (BOOL)canAddNeedsDiamond;
- (void)addNeedsDiamondToObject:(id)diamondOwner;
- (void)addNeedsDiamondToSelectedObject;
- (void)setDefaultNeedsDiamondValue:(NSString *)value forKey:(NSString *)key;

- (IBAction)deleteSelectedObjects:(id)sender;
- (void)deleteSelectedObjects;
- (void)deleteObject:(id)anObject;

- (void)setAllSelectedEventsWithLabel:(NSNumber *)label;

- (void)setTableViewRowHeight;
- (int)tableViewRowHeight;

- (void)reload;
- (void)redisplay;

- (void)snapChartToTimes;
- (void)snapTimesToChart;

- (NSMutableArray *)selectedObjects;

- (void)validateEventBeginTime:(SSEventObject *)event;
- (BOOL)eventExistsWithActorAndTime:(SSEventObject *)event;

- (NSString *)addressForNewEvent;

- (float)actorColumnWidth;

- (void)setLegendViewDisplay;
- (void)addLegendView;
- (void)removeLegendView;

- (void)setIncrementedTimeForEBBasedOnPrevious:(NSMenuItem *)item;
- (void)setIncrementedTimeForEBBasedOnNext:(NSMenuItem *)item;

- (SSJumpMapView *)jumpMapView;
- (void)addJumpMapToChartView;
- (void)removeJumpMapFromChartView;

- (SSTablePrintView *)printViewForEventPanel;
- (SSTablePrintView *)printViewForCommentPanel;
- (SSTablePrintView *)printViewForDiamondPanel;

- (SSEventObject *)currentLinkFromEvent;

- (void)saveBackupCopy;

- (void)addSkippedEvent:(SSEventObject *)event;

- (SSEventObject *)closestEventToComment:(SSCatalystComment *)comment;

- (SSObjectFilterController *)objectFilterController;

- (void)showInspectorPanel;
- (void)showObjectFilterPanel;

- (void)zoomIn;
- (void)zoomOut;
- (float)chartViewScale;
- (void)zoomOverlapIn;
- (void)zoomOverlapOut;
- (BOOL)canZoomIn;
- (BOOL)canZoomOut;
- (BOOL)canZoomOverlapIn;
- (BOOL)canZoomOverlapOut;

- (float)overlapUnit;
- (void)setOverlapUnit:(float)unit;
- (float)overlapPixelsPerUnit;
- (void)setOverlapPixelsPerUnit:(float)pix;
- (int)displayMode;
- (void)setDisplayMode:(int)mode;
- (void)switchDisplayMode;

- (SSChartDate *)overlapViewFromDate;
- (SSChartDate *)overlapViewToDate;

- (SSChartDate *)earliestEBBeginTime;
- (SSChartDate *)latestEBEndTime;

- (void)updateObjectVisibility;

- (void)promptUserOnOutOfRangeEBs;

- printPanelAccessoryView;

- (SSDateDisplayView *)dateDisplayView;
- (SSChartView *)chartView;

- (NSMutableArray *)poisonWordArray;
- (void)addPoisonWord:(SSPoisonWord *)word;
- (void)removePoisonWord:(SSPoisonWord *)word;

- (NSMutableArray *)allEventsContainingString:(NSString *)string;
- (NSMutableArray *)allEventsWithActorContainingString:(NSString *)string;
- (NSMutableArray *)allEventsWithActionContainingString:(NSString *)string;
- (NSMutableArray *)allEventsWithObjectContainingString:(NSString *)string;
- (NSMutableArray *)allEventsWithSourceContainingString:(NSString *)string;
- (NSMutableArray *)allEventsWithLocationContainingString:(NSString *)string;
- (NSMutableArray *)allEventsWithRemarkContainingString:(NSString *)string;
- (NSMutableArray *)allEventsWithBeginDate:(NSCalendarDate *)date;
- (NSMutableArray *)allEventsWithBeginTime:(NSCalendarDate *)date;
- (NSMutableArray *)allEventsWithEndDate:(NSCalendarDate *)date;
- (NSMutableArray *)allEventsWithEndTime:(NSCalendarDate *)date;
- (NSMutableArray *)allCommentsContainingString:(NSString *)string;
- (NSMutableArray *)allDiamondsContainingString:(NSString *)string;

@end
